CustomButtonWidget

A custom ButtonWidget implementation with builder and rendering improvements (and more features in general)

This constructor is for subclasses of this widget only. Buttons should be constructed with the builder, like vanilla buttons.

Author

fzzyhmstrs

Since

0.5.?, update to ActiveNarrationSupplier 0.6.3, improve memory footprint 0.6.5

Parameters

x

button X position

y

button Y position

width

button width in pixels

height

button height in pixels

pressAction

Consumer<CustomButtonWidget> action to invoke when the button is clicked or activated

narrationSupplier

ActiveNarrationSupplier converts a provided input text and the current active state of this widget into a narration text.

narrationAppender

Consumer<NarrationMessageBuilder> unlike the supplier, this is used to directly append additional narrations as needed to the message builder.

textures

TextureSet, default CustomPressableWidget.DEFAULT_TEXTURES. The textures for this button

child

TooltipChild, used to pass additional tooltip context. This button will pass and tooltip from this child out to its own parent (this button is also a TooltipChild)

renderMessage

If false, the label won't be rendered

Types

Link copied to clipboard
class Builder(message: Text, onPress: Consumer<CustomButtonWidget>)
Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var x: Int
Link copied to clipboard
var y: Int

Functions

Link copied to clipboard
override fun appendNarrations(builder: NarrationMessageBuilder)
Link copied to clipboard
open fun drawMessage(context: DrawContext, textRenderer: TextRenderer, x: Int, y: Int, width: Int, height: Int, color: Int)

Draws the widgets message with standard edge padding and positioning.

Link copied to clipboard
open override fun forEachChild(consumer: Consumer<ClickableWidget>)
Link copied to clipboard
open fun getAlpha(): Float
Link copied to clipboard
open fun getBorder(direction: NavigationDirection): ScreenRect
Link copied to clipboard
open fun getBottom(): Int
Link copied to clipboard
open fun getFocusedPath(): @Nullable GuiNavigationPath
Link copied to clipboard
open override fun getHeight(): Int
Link copied to clipboard
open override fun getMessage(): Text
Link copied to clipboard
open fun getNarratedParts(): MutableCollection<out Selectable>
Link copied to clipboard
open override fun getNavigationFocus(): ScreenRect
Link copied to clipboard
open override fun getNavigationPath(navigation: GuiNavigation): @Nullable GuiNavigationPath
Link copied to clipboard
open fun getRight(): Int
Link copied to clipboard
open override fun getType(): Selectable.SelectionType
Link copied to clipboard
open override fun getWidth(): Int
Link copied to clipboard
open fun isClickable(): Boolean
Link copied to clipboard
open fun isHovered(): Boolean
Link copied to clipboard
open override fun isInteractable(): Boolean
Link copied to clipboard
Link copied to clipboard
open override fun isMouseOver(mouseX: Double, mouseY: Double): Boolean
Link copied to clipboard
open fun isSelected(): Boolean
Link copied to clipboard
open fun mouseMoved(mouseX: Double, mouseY: Double)
Link copied to clipboard

Handles char input events for custom widgets. Override this for handling keyboard inputs.

Link copied to clipboard
open override fun onKey(event: CustomWidget.KeyEvent): Boolean

Handles keyboard events for custom widgets. Override this for handling keyboard inputs.

Link copied to clipboard

Handles keyboard release events for custom widgets. Override this for handling keyboard inputs.

Link copied to clipboard
open override fun onMouse(event: CustomWidget.MouseEvent): Boolean

Handles mouse click events for custom widgets. Override this or onPress for handling mouse inputs.

Link copied to clipboard

Handles mouse drag events for custom widgets. Override this for handling drag inputs

Link copied to clipboard

Handles mouse button release events for custom widgets. Override this for handling mouse inputs.

Link copied to clipboard

Handles mouse scroll events for custom widgets. Override this for handling mouse inputs.

Link copied to clipboard
open override fun onPress()

Action invoked whenever the button is clicked on or activated with Enter.

Link copied to clipboard
open fun playDownSound(soundManager: SoundManager)
Link copied to clipboard
open fun provideNarrationLines(): List<Text>

Provides a list of text for appending into a Narration Hint. By default this will use the same lines passed from provideTooltipLines, with predefined values for the inputs

Link copied to clipboard
open override fun provideTooltipLines(mouseX: Int, mouseY: Int, parentSelected: Boolean, keyboardFocused: Boolean): List<Text>

Provides a list of text lines for appending to a tooltip. Unlike appending in MC, the parent has final say on compiling the tooltip from the pieces given to it.

Link copied to clipboard
override fun render(context: DrawContext, mouseX: Int, mouseY: Int, deltaTicks: Float)
Link copied to clipboard
open override fun renderBackground(context: DrawContext, x: Int, y: Int, width: Int, height: Int, mouseX: Int, mouseY: Int, delta: Float)

Custom background rendering for the widget. By default, will render the standard MC button texture set.

Link copied to clipboard
open override fun renderCustom(context: DrawContext, x: Int, y: Int, width: Int, height: Int, mouseX: Int, mouseY: Int, delta: Float)

Custom foreground rendering for the widget. By default, will render the label.

Link copied to clipboard
open fun setAlpha(alpha: Float)
Link copied to clipboard
open fun setDimensions(width: Int, height: Int)
Link copied to clipboard
open fun setDimensionsAndPosition(width: Int, height: Int, x: Int, y: Int)
Link copied to clipboard
open fun setHeight(height: Int)
Link copied to clipboard
open fun setMessage(message: Text)
Link copied to clipboard
open fun setPosition(x: Int, y: Int)
Link copied to clipboard
open fun setTooltip(tooltip: @Nullable Tooltip)
Link copied to clipboard
open fun setTooltipDelay(tooltipDelay: Duration)
Link copied to clipboard
open fun setWidth(width: Int)